﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace PhysicsSimulator
{
    class ConvertUnits
    {
        private static float _displayUnitstoSimUnitsRatio = 100f;//default ratio
        private static float _simUnitstoDisplayUnitsRatio = 1 / _displayUnitstoSimUnitsRatio;

        /// <summary>
        /// Set the ratio, defaul is 100f;
        /// </summary>
        /// <param name="value"></param>
        public static void DisplayToSimRatio(float value)
        {
            _displayUnitstoSimUnitsRatio = value;
            _simUnitstoDisplayUnitsRatio = 1 / _displayUnitstoSimUnitsRatio;
        }

        /// <summary>
        /// Convert sim(float) value to display value
        /// </summary>
        /// <param name="sim_units"></param>
        /// <returns></returns>
        public static float ToDisplayUnits(float sim_units)
        {
            return sim_units * _displayUnitstoSimUnitsRatio;
        }

        public static Vector2 ToDisplayUnits(Vector2 sim_units)
        {
            return sim_units * _displayUnitstoSimUnitsRatio;
        }

        /// <summary>
        /// Convert display units to sim units 
        /// </summary>
        /// <param name="dis_units"></param>
        /// <returns></returns>
        public static float ToSimUnits(float dis_units)
        {
            return dis_units * _simUnitstoDisplayUnitsRatio;
        }

        public static Vector2 ToSimUnits(Vector2 dis_units)
        {
            return dis_units * _simUnitstoDisplayUnitsRatio;
        }
    }
}
